import itertools

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# 前5个元素
sliced_numbers = itertools.islice(numbers, 5)

for number in sliced_numbers:
    print(number)



letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

# 从索引2到索引7的元素
sliced_letters = itertools.islice(letters, 2, 7)

for letter in sliced_letters:
    print(letter)